const config = require('./config/database')
const mysql = require('mysql2/promise')

async function checkSchema () {
  try {
    const connection = await mysql.createConnection({
      host: config.host,
      user: config.user,
      password: config.password,
      database: config.database
    })

    console.log('=== AUTHORS 表结构 ===')
    const [authorsSchema] = await connection.execute('DESCRIBE authors')
    console.table(authorsSchema)

    console.log('\n=== NOVELS 表结构 ===')
    const [novelsSchema] = await connection.execute('DESCRIBE novels')
    console.table(novelsSchema)

    console.log('\n=== CHAPTERS 表结构 ===')
    const [chaptersSchema] = await connection.execute('DESCRIBE chapters')
    console.table(chaptersSchema)

    await connection.end()
  } catch (error) {
    console.error('查看表结构错误:', error)
  }
}

checkSchema()
